﻿// For an introduction to the Page Control template, see the following documentation:
// http://go.microsoft.com/fwlink/?LinkId=232511
(function () {
    "use strict";

    WinJS.UI.Pages.define("/pages/add/add.html", {

        // NOTE: ready is another event in the lifetime of a Page control and the third major one after
        //       init and processed. Frequently you can just put all your logic in ready and call it done.
        ready: function () {
            var that = this;
            this.element.querySelector(".ok").addEventListener("click", function () {
                var value = that.element.querySelector(".zip").value;

                Data.getBingData(value).then(function (item) {
                    Data.list.push(item);
                }, function () {
                    // NOTE: In a real app you might handle failures gracefully, here we ignore them.
                });

                WinJS.Navigation.navigate("/pages/home/home.html");
            });
        },

    });
})();
